import DeleteImageDto from "../utils/dto/image/deleteImageDto";
import {$host} from "./index";

export const uploadImage = async (image: File) => {
    const formData = new FormData();
    formData.append('image', image);
    return await $host.post('api/Image/UploadImage', formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

export const getImageById = (id: string | null | undefined) => {
    if (id)
        return `${process.env.REACT_APP_GAMFI_API}api/Image/GetImageById/${id}`
    else
        return ''
}

export const deleteImage = async (dto: DeleteImageDto) => {
    return await $host.delete('api/Image/DeleteImage', {data: dto})
}